﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace Tin
{
    class TTriangle
    {
        public TPoint Point1 { set; get; }
        public TPoint Point2 { set; get; }
        public TPoint Point3 { set; get; }

        public TEdge Edge1
        {
            get { return new TEdge(Point1, Point2); }
        }
        public TEdge Edge2
        {
            get { return new TEdge(Point2, Point3); }
        }
        public TEdge Edge3
        {
            get { return new TEdge(Point3, Point1); }
        }

        public void render(Graphics g)
        {
            float sx = g.Transform.Elements[0];
            float sy = g.Transform.Elements[3];
            float pen_width = 1.0f / (sx - sy) * 2;
            Pen pen = new Pen(Color.Blue, pen_width);
            Brush brush = new SolidBrush(Color.Red);

            GraphicsPath path = new GraphicsPath();
            PointF[] temp = new PointF[3];
            temp[0].X = Convert.ToSingle(Point1.X);
            temp[0].Y = Convert.ToSingle(Point1.Y);
            temp[1].X = Convert.ToSingle(Point2.X);
            temp[1].Y = Convert.ToSingle(Point2.Y);
            temp[2].X = Convert.ToSingle(Point3.X);
            temp[2].Y = Convert.ToSingle(Point3.Y);

            path.AddPolygon(temp);
            g.DrawPath(pen, path);


        }
    }
}
